package com.sgb.kjwl.view.ui.fragment.chat;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;

import com.sgb.kjwl.AppLazyFragment;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.FrNewsNoticeViewBinding;
import com.sgb.kjwl.model.entity.chat.NewsNoticeEntity;
import com.sgb.kjwl.view.ui.adapter.chat.NewsNoticeTypeAdapter;
import com.sgb.kjwl.viewmodel.chat.ChatNewsModel;
import com.swgk.core.mmkvutil.CacheMarker;
import com.swgk.core.mmkvutil.MkvUtils;
import com.swgk.core.xrecyclerview.XRecyclerMaxView;
import com.swgk.core.xrecyclerview.XRecyclerView;

import java.util.List;


public class NewsNoticeFragment extends AppLazyFragment implements SwipeRefreshLayout.OnRefreshListener {

    private FrNewsNoticeViewBinding binding;
    private ChatNewsModel viewModel;
    private String mItemType;
    private int currentPage = 1;

    //订单配适配
    private NewsNoticeTypeAdapter orderAdapter;
    //询价适配器
    private NewsNoticeTypeAdapter enquiryPriceAdapter;
    //函询适配器
    private NewsNoticeTypeAdapter letterInquiriesAdapter;
    //邀请适配器
    private NewsNoticeTypeAdapter inviteAdapter;
    //商品材料适配器
    private NewsNoticeTypeAdapter materialAdapter;
    //招标竞价适配器
    private NewsNoticeTypeAdapter recruitmentAdapter;
    //集团采购适配器
    private NewsNoticeTypeAdapter groupPurchaseAdapter;
    //租赁转让适配器
    private NewsNoticeTypeAdapter leaseAdapter;
    //工队工人适配器
    private NewsNoticeTypeAdapter workTeamAdapter;
    //物流货运适配器
    private NewsNoticeTypeAdapter logisticsAdapter;
    //会员经营适配器
    private NewsNoticeTypeAdapter memberOperatingAdapter;
    //企业经营适配器
    private NewsNoticeTypeAdapter companyOperatingAdapter;
    //企业服务适配器
    private NewsNoticeTypeAdapter companyServerAdapter;
    //招商引资适配器
    private NewsNoticeTypeAdapter attractInvestmentAdapter;
    //商机服务适配器
    private NewsNoticeTypeAdapter businessServerAdapter;
    //系统通知适配器
    private NewsNoticeTypeAdapter systemNotifyAdapter;

    public static NewsNoticeFragment newInstance(String type) {
        NewsNoticeFragment dialog = new NewsNoticeFragment();
        Bundle bundle = new Bundle();
        bundle.putString("type", type);
        dialog.setArguments(bundle);
        return dialog;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            getItemType();
        }
    }

    public void getItemType() {
        mItemType = getArguments().getString("type", "");
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fr_news_notice_view, container, false);
        viewModel = new ViewModelProvider(getActivity()).get(ChatNewsModel.class);
        return binding.getRoot();
    }

    private void requestNoticeList(boolean isLoadMore) {
        String timelineId = MkvUtils.get().getString(MkvUtils.get().CacheUserCenterMenu, CacheMarker.IM_NOTICE_TIME_ID, "");
        if (isLoadMore) {
            currentPage = currentPage + 1;
        } else {
            currentPage = 1;
        }
        viewModel.getNoticeListByType(timelineId, mItemType, currentPage, isLoadMore);
    }

    @Override
    protected void initView() {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, true);
        linearLayoutManager.setStackFromEnd(true);
        binding.recycler.setLayoutManager(linearLayoutManager);
        binding.swipeLayout.setOnRefreshListener(this);

        switch (mItemType) {
            case "order"://订单
                initOrderView();
                break;
            case "enquiry_price"://询价
                initEnquiryPriceView();
                break;
            case "letter_inquiries"://函询
                initLetterInquiriesView();
                break;
            case "invite"://邀请
                initInviteView();
                break;
            case "material"://商品材料
                initMaterialView();
                break;
            case "recruitment"://招标竞价
                initRecruitmentView();
                break;
            case "group_purchase"://集团采购
                initGroupPurchaseView();
                break;
            case "lease"://租赁转让
                initLeaseView();
                break;
            case "work_team"://工队工人
                initWorkTeamView();
                break;
            case "logistics"://物流货运
                initLogisticsView();
                break;
            case "member_operating"://会员经营
                initMemberOperatingView();
                break;
            case "company_operating"://企业经营
                initCompanyOperatingView();
                break;
            case "company_server"://企业服务
                initCompanyServerView();
                break;
            case "attract_investment"://招商引资
                initAttractInvestmentView();
                break;
            case "business_server"://商机服务
                initBusinessServerView();
                break;
            case "system_notify"://系统通知
                initSystemNotifyView();
                break;
        }
    }

    @Override
    public void onRefresh() {
        requestNoticeList(true);
    }

    @Override
    protected void onLazyLoad() {
        requestNoticeList(false);
    }

    @Override
    public void onVisible() {
        requestNoticeList(false);
    }

    /**
     * 通知订单布局
     */
    private void initOrderView() {
        viewModel.NoticeList1.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                if (list.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (orderAdapter != null)
                        orderAdapter.setDatas(list);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore1.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    orderAdapter.addDatas(list);
                }
            }
        });
        orderAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(orderAdapter);
    }

    /**
     * 通知询价布局
     */
    private void initEnquiryPriceView() {
        viewModel.NoticeList2.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                if (list.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (enquiryPriceAdapter != null)
                        enquiryPriceAdapter.setDatas(list);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore2.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    enquiryPriceAdapter.addDatas(list);
                }
            }
        });
        enquiryPriceAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(enquiryPriceAdapter);
    }

    /**
     * 通知函询布局
     */
    private void initLetterInquiriesView() {
        viewModel.NoticeList3.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (letterInquiriesAdapter != null)
                        letterInquiriesAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore3.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    letterInquiriesAdapter.addDatas(list);
                }
            }
        });
        letterInquiriesAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(letterInquiriesAdapter);
    }

    /**
     * 通知邀请布局
     */
    private void initInviteView() {
        viewModel.NoticeList4.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (inviteAdapter != null)
                        inviteAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore4.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    inviteAdapter.addDatas(list);
                }
            }
        });
        inviteAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(inviteAdapter);
    }

    /**
     * 通知商品材料布局
     */
    private void initMaterialView() {
        viewModel.NoticeList5.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (materialAdapter != null)
                        materialAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore5.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    materialAdapter.addDatas(list);
                }
            }
        });
        materialAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(materialAdapter);
    }

    /**
     * 通知招标竞价布局
     */
    private void initRecruitmentView() {
        viewModel.NoticeList6.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (recruitmentAdapter != null)
                        recruitmentAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore6.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    recruitmentAdapter.addDatas(list);
                }
            }
        });
        recruitmentAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(recruitmentAdapter);
    }

    /**
     * 通知集团采购布局
     */
    private void initGroupPurchaseView() {
        viewModel.NoticeList7.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (groupPurchaseAdapter != null)
                        groupPurchaseAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore7.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    groupPurchaseAdapter.addDatas(list);
                }
            }
        });
        groupPurchaseAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(groupPurchaseAdapter);
    }

    /**
     * 通知租赁布局
     */
    private void initLeaseView() {
        viewModel.NoticeList8.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (leaseAdapter != null)
                        leaseAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore8.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    leaseAdapter.addDatas(list);
                }
            }
        });
        leaseAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(leaseAdapter);
    }

    /**
     * 通知工队工人布局
     */
    private void initWorkTeamView() {
        viewModel.NoticeList9.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (workTeamAdapter != null)
                        workTeamAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore9.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    workTeamAdapter.addDatas(list);
                }
            }
        });
        workTeamAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(workTeamAdapter);
    }

    /**
     * 通知物流货运布局
     */
    private void initLogisticsView() {
        viewModel.NoticeList10.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (logisticsAdapter != null)
                        logisticsAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore10.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    logisticsAdapter.addDatas(list);
                }
            }
        });
        logisticsAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(logisticsAdapter);
    }

    /**
     * 通知会员经营布局
     */
    private void initMemberOperatingView() {
        viewModel.NoticeList11.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (memberOperatingAdapter != null)
                        memberOperatingAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore11.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    memberOperatingAdapter.addDatas(list);
                }
            }
        });
        memberOperatingAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(memberOperatingAdapter);
    }

    /**
     * 通知企业经营布局
     */
    private void initCompanyOperatingView() {
        viewModel.NoticeList12.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (companyOperatingAdapter != null)
                        companyOperatingAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore12.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    companyOperatingAdapter.addDatas(list);
                }
            }
        });
        companyOperatingAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(companyOperatingAdapter);
    }

    /**
     * 通知企业服务布局
     */
    private void initCompanyServerView() {
        viewModel.NoticeList13.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (companyServerAdapter != null)
                        companyServerAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore13.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    companyServerAdapter.addDatas(list);
                }
            }
        });
        companyServerAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(companyServerAdapter);
    }

    /**
     * 通知招商引资布局
     */
    private void initAttractInvestmentView() {
        viewModel.NoticeList14.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (attractInvestmentAdapter != null)
                        attractInvestmentAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore14.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    attractInvestmentAdapter.addDatas(list);
                }
            }
        });
        attractInvestmentAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(attractInvestmentAdapter);
    }

    /**
     * 通知商机服务布局
     */
    private void initBusinessServerView() {
        viewModel.NoticeList15.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (businessServerAdapter != null)
                        businessServerAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore15.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    businessServerAdapter.addDatas(list);
                }
            }
        });
        businessServerAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(businessServerAdapter);
    }

    /**
     * 通知系统通知布局
     */
    private void initSystemNotifyView() {
        viewModel.NoticeList16.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> newsMenuEntities) {
                if (newsMenuEntities.size() > 0) {
                    binding.recycler.setVisibility(View.VISIBLE);
                    binding.emptyView.setVisibility(View.GONE);
                    if (systemNotifyAdapter != null)
                        systemNotifyAdapter.setDatas(newsMenuEntities);
                } else {
                    binding.recycler.setVisibility(View.GONE);
                    binding.emptyView.setVisibility(View.VISIBLE);
                }
                binding.recycler.scrollToPosition(0);
            }
        });
        viewModel.NoticeListMore16.observe(getActivity(), new Observer<List<NewsNoticeEntity>>() {
            @Override
            public void onChanged(List<NewsNoticeEntity> list) {
                binding.swipeLayout.setRefreshing(false);
                if (list.size() > 0) {
                    systemNotifyAdapter.addDatas(list);
                }
            }
        });
        systemNotifyAdapter = new NewsNoticeTypeAdapter(getActivity(), null);
        binding.recycler.setAdapter(systemNotifyAdapter);
    }
}
